import request from "./Request.js";

/**
 * 注册账号
 */
export function register(email, username, password, checkCode) {
	return request({
		url: "/user/register",
		data: {
			username: username,
			password: password,
			checkCode: checkCode
		},
		method: "POST",
		useLocalEmail: false,
		email: email
	});
}

/**
 * 修改密码
 */
export function forget(email, password, checkCode) {
	return request({
		url: "/user/forget",
		data: {
			email: email,
			password: password,
			checkCode: checkCode
		},
		method: "POST",
		useLocalEmail: false,
		email: email
	});
}

/**
 * 获取其他用户个人信息
 */
export function getInfo(userEmail) {
	return request({
		url: "/user/info",
		data: {
			userEmail: userEmail
		},
		method: "GET"
	});
}

/**
 * 获取个人信息
 */
export function getMyInfo() {
	return request({
		url: "/user/myInfo",
		method: "GET"
	});
}

/**
 * 修改用户简介
 */
export function updateProfile(profile) {
	return request({
		url: "/user/profile",
		data: {
			profile: profile
		},
		method: "POST"
	});
}

/**
 * 修改用户资料
 */
export function updateUser(username, gender, birth, school) {
	return request({
		url: "/user",
		data: {
			username: username,
			gender: gender,
			birth: birth,
			school: school
		},
		method: "POST"
	});
}

/**
 * 添加关注
 */
export function addFollow(followEmail) {
	return request({
		url: "/user/follow",
		data: {
			followEmail: followEmail
		},
		method: "POST"
	});
}

/**
 * 取消关注
 */
export function deleteFollow(followEmail) {
	return request({
		url: "/user/follow",
		data: {
			followEmail: followEmail
		},
		method: "DELETE"
	});
}

/**
 * 获取我关注的人
 */
export function getFollow() {
	return request({
		url: "/user/follow",
		method: "GET"
	});
}

/**
 * 获取我的粉丝
 */
export function getFan() {
	return request({
		url: "/user/fan",
		method: "GET"
	});
}

/**
 * 判断是否关注另一个用户
 */
export function isFollow(followEmail) {
	return request({
		url: "/user/isFollow",
		data: {
			followEmail: followEmail
		},
		method: "GET"
	});
}